package com.zzh.dialog.tag;


import android.graphics.Color;
import android.os.Bundle;
import android.view.View;

import com.zzh.dialog.databinding.ActTagBinding;
import com.zzh.dialog.databinding.ItemTagBinding;
import com.zzh.lib.bar.java.UltimateBarX;
import com.zzh.lib.views.flow.HFlowLayout;
import com.zzh.lib.views.flow.TagAdapter;

import java.util.ArrayList;
import java.util.List;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;

/**
 * Created by zzh on 2023/11/16.
 *
 * @date: 2023/11/16 11:14
 * @email: zzh_hz@126.com
 * @author: zzh
 * @description: com.zzh.dialog.tag
 */
public class TagActivity extends AppCompatActivity {

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        UltimateBarX.getStatusBar(this).light(true).fitWindow(true).apply();
        ActTagBinding bind = ActTagBinding.inflate(getLayoutInflater());
        setContentView(bind.getRoot());

        List<String> list = new ArrayList<>();
        for (int i = 0; i < 22; i++) {
            list.add(String.valueOf(i));
        }
        bind.tag.getSelectedList();
        bind.tag.setAdapter(new TagAdapter(list) {
            @Override
            public View getView(HFlowLayout parent, int position, Object o) {
                ItemTagBinding inflate = ItemTagBinding.inflate(getLayoutInflater());
                inflate.text.setText(String.valueOf(o));
                return inflate.getRoot();
            }

            @Override
            public void onSelected(int position, View view) {
                view.setBackgroundColor(Color.RED);
            }

            @Override
            public void unSelected(int position, View view) {
                view.setBackgroundColor(Color.BLUE);
            }
        });
    }
}
